package com.baosight.sczx.zp.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.ef.ui.tree.TreeService;
import com.baosight.sczx.common.zp.ZPUtils;
import com.baosight.iplat4j.core.FrameworkInfo;

/**
 * <p>Title: ServiceZP21.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 梁琦
 * @version 1.0
 * <pre>Histroy:
 *          2012-10-22 上午06:27:44  梁琦  Create
 *</pre>
 */
public class ServiceZP21 extends TreeService {	
	
	/**
	 * 查找子节点
	 * <p>Function: getChildNodes</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZP21</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-10-22 上午06:27:44  梁琦
	 * </p>
	 *
	 */
	@Override
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List getChildNodes(String arg0) {
		Map<String, String> _argMap = new HashMap<String, String>();
		_argMap.put("projectEname", FrameworkInfo.getProjectEname().toUpperCase());
		_argMap.put("Projectprefix",FrameworkInfo.getProjectPrefix());
		List<Map> childNodes = dao.query("ZPModle.query", _argMap);
		for(Map map : childNodes){
			map.put("text", map.get("moduleEname"));
			map.put("label", map.get("moduleCname")+"("+map.get("moduleEname")+")");
			map.put("leaf", 1);
		}
		return childNodes;
	}

	/**
	 * 查找根节点
	 * <p>Function: getTopNodes</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZP21</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-10-22 上午06:27:44  梁琦
	 * </p>
	 *
	 */
	@Override
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List getTopNodes() {
		List ret = new ArrayList();
		Map row = new HashMap();
		row.put("text", ZPUtils.USER_COMPANY_ID);
		row.put("label", "系统模块");
		row.put("leaf", 0);
		ret.add(row);
		
		return ret;
	}

	/**
	 * <p>Function: initMetaData</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZP21</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-10-22 上午06:27:44  梁琦
	 * </p>
	 *
	 */
	@Override
	public EiBlockMeta initMetaData() {
		EiBlockMeta eiMetadata = new EiBlockMeta();

		EiColumn eiColumn = new EiColumn("label");
		eiColumn.setDescName("label");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn("text");
		eiColumn.setDescName("text");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn("leaf");
		eiColumn.setDescName("leaf");
		eiColumn.setType(EiConstant.COLUMN_TYPE_NUMBER);
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);
		return eiMetadata;
	}

}
